<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="企业资料维护">
    <link rel="stylesheet" href="${baseUrl}css/public.css" media="all">
    <script>
        jQuery(function () {
            var ajaxIndustry = get("${baseUrl}industry/getAll.action",function (resp) {
                var $select = $("[name='industryId']");
                $select.empty();
                $.each(resp.data,function (i,data) {
                    $select.append("<option value='"+data.id+"'>"+data.name+"</option>");
                });
                formRender();
            });
            $.when(ajaxIndustry).done(function () {
                //要执行的操作
                get("${baseUrl}account/getUserCompany.action",function (resp) {
                    var data = {};
                    data.id= resp.data.id;
                    data.code= resp.data.code;
                    data.account= resp.data.account;
                    data.userNumber= resp.data.userNumber;
                    data.name= resp.data.name;
                    data.startDate= GMTToDate(resp.data.startDate);
                    data.endDate= GMTToDate(resp.data.endDate);
                    data.adminName= resp.data.adminName;
                    data.address= resp.data.address;
                    data.industryId= resp.data.industryId;
                    data.website= resp.data.website;
                    data.contacts= resp.data.contacts;
                    data.phone= resp.data.phone;
                    data.email= resp.data.email;
                    data.qq = resp.data.qq;
                    data.remark= resp.data.remark;
                    data.code= resp.data.code;
                    formSetVal("companyData",data);
                });
            });

            layui.use(['form', 'layedit', 'laydate','element'], function(){
                var form = layui.form
                    ,layer = layui.layer
                    ,layedit = layui.layedit
                    ,laydate = layui.laydate
                    ,element = layui.element;
                form.render('select');

                //监听提交
                form.on('submit(save)', function(data){
                    console.log(JSON.stringify(data.field));
                    delete data.field.userNumber;
                    data.field.startDate = genDate(data.field.startDate);
                    data.field.endDate = genDate(data.field.endDate);
                    post("${baseUrl}account/update.action", data.field,function (res) {
                        if (res.code == 1) {
                            tip("保存成功");
                        } else {
                            tip(res.msg);
                        }
                    });
                    return false;
                });
            });
        });
    </script>
</html:header>
<body  style="background-color:#ffffff;">
        <form class="layui-form" action="" lay-filter="companyData">
            <input type="hidden" name="id" />

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">商户代码</label>
                    <div class="layui-input-inline">
                        <input type="text" id="code" name="code" style="background-color: #eeeeee" readonly="readonly"  class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">管理员账号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="account" style="background-color: #eeeeee" readonly="readonly" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">用户数</label>
                    <div class="layui-input-inline">
                        <input type="text" name="userNumber" style="background-color: #eeeeee" readonly="readonly" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">商户名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" autocomplete="off" placeholder="商户名称" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">开户日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="startDate" style="background-color: #eeeeee" readonly="readonly" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">到期日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="endDate" value="${companyVo.endDate}" style="background-color: #eeeeee" readonly="readonly" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">管理员姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="adminName" autocomplete="off" placeholder="管理员姓名" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">公司地址</label>
                    <div class="layui-input-inline">
                        <input type="text" name="address" autocomplete="off" placeholder="公司地址" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">所属行业</label>
                    <div class="layui-input-inline">
                        <select name="industryId" disabled>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">网址</label>
                    <div class="layui-input-inline">
                        <input type="text" name="website" autocomplete="off" placeholder="网址" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-inline">
                        <input type="text" name="contacts" autocomplete="off" placeholder="联系人" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">联系电话</label>
                    <div class="layui-input-inline">
                        <input type="phone" name="phone" autocomplete="off" placeholder="联系电话" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">电子邮箱</label>
                    <div class="layui-input-inline">
                        <input type="email" name="email" autocomplete="off" placeholder="电子邮箱" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">QQ账号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="qq" autocomplete="off" placeholder="QQ账号" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <textarea name="remark" class="layui-textarea">${companyVo.remark}</textarea>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="save">提交</button>
                </div>
            </div>
        </form>
</body>
</html>